﻿using System.Windows;
using JiaBao.Core.Infrastructure;
using JiaBao.Services.ServerState;
using JiaBao.WPF.Framework;
using JiaBao.WPF.Setting;

namespace JiaBao.WPF
{
    /// <summary>
    /// Loading.xaml 的交互逻辑
    /// </summary>
    public partial class Loading : Window, IRegistrarWPFForm
    {
        private readonly IServerState _serverState;

        public Loading(IServerState serverState)
        {
            InitializeComponent();
            _serverState = serverState;
           
            AppStart.type = 1;
        }

        private void Window_ContentRendered(object sender, System.EventArgs e)
        {
            // 检测数据库
            if (!_serverState.IsReady())
            {
                var server = EngineContext.Current.Resolve<W_ServerSetting>();
                server.ShowDialog();
            }
            Close();
            
        }
    }
}
